<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:34:"./themes/admin/admin_user\add.html";i:1741049647;s:39:"D:\phpcode\syzth\themes\admin\base.html";i:1741049647;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<!--tab标签-->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class=""><a href="<?php echo url('admin/admin_user/index'); ?>">管理员管理</a></li>
                <li class="layui-this">添加管理员</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form" action="<?php echo url('admin/admin_user/save'); ?>" method="post">
                        <div class="layui-form-item">
                            <label class="layui-form-label">管理员名</label>
                            <div class="layui-input-block">
                                <input type="text" name="user_name" value=""  lay-verify="username" placeholder="请输入管理员名" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="pass_word" value="" placeholder="请输入密码" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">重复密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="confirm_pass_word" value="" required lay-verify="required" placeholder="请再次输入密码" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">头像</label>
                            <div class="layui-input-block">
                                <img id="imgsrc" src="" onerror="this.src='/public/static/images/wutu.jpg'" style="width:50px;height:50px;margin-right:10px;border-radius:50%">
                                <button type="button" class="layui-btn" id="test1">
                                    <i class="layui-icon">&#xe67c;</i>上传头像
                                </button>
                                <input type="hidden" name="img" id="img" value="">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">姓名</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" value="" placeholder="（选填）请输入姓名" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机</label>
                            <div class="layui-input-block">
                                <input type="text" name="mobile" value="" placeholder="（选填）请输入手机" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" name="email" value="" placeholder="（选填）请输入邮箱" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">地址</label>
                            <div class="layui-input-block">
                                <input type="text" name="address" value="" placeholder="（选填）请输入地址" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">部门</label>
                            <div class="layui-input-inline">
                                <select name="did" lay-skin="select" lay-filter="did">
                                    <option value="">请选择部门</option>
                                    <?php if(is_array($department_list) || $department_list instanceof \think\Collection || $department_list instanceof \think\Paginator): if( count($department_list)==0 ) : echo "" ;else: foreach($department_list as $key=>$vo): ?>
                                    <option value="<?php echo $vo['id']; ?>"><?php echo $vo['title']; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">权限组</label>
                            <div class="layui-input-inline">
                                <select name="group_id" lay-verify="required">
                                    <?php if(is_array($auth_group_list) || $auth_group_list instanceof \think\Collection || $auth_group_list instanceof \think\Paginator): if( count($auth_group_list)==0 ) : echo "" ;else: foreach($auth_group_list as $key=>$vo): ?>
                                    <option value="<?php echo $vo['id']; ?>"><?php echo $vo['title']; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-block">
                                <input type="radio" name="status" value="1" title="启用" checked="checked">
                                <input type="radio" name="status" value="0" title="禁用">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="*">保存</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
    layui.use(['form','layer','upload'], function(){
        var form = layui.form,$ = layui.jquery, layer = layui.layer,upload = layui.upload;

        //自定义验证规则
        form.verify({
            username: function(value){
                if(value.length < 5){
                    return '用户名至少得5个字符';
                }
            }
        });

        /**
         * 通用表单提交(AJAX方式)
         */
        form.on('submit(*)', function (data) {
            $.ajax({
                url: data.form.action,
                type: data.form.method,
                data: $(data.form).serialize(),
                success: function (info) {
                    if (info.code === 1) {
                        setTimeout(function () {
                            location.href = info.url;
                        }, 1000);
                    }
                    layer.msg(info.msg);
                }
            });

            return false;
        });

        /**
         * 通用单图上传
         */
        var uploadInst = upload.render({
            elem: "#test1" //绑定元素
            ,url: "<?php echo url('api/upload/img'); ?>" //上传接口
            ,before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                layer.load(); //上传loading
            }
            ,done: function(res, index, upload){
                layer.closeAll('loading'); //关闭loading
                if (res.error === 0) {
                    $('#imgsrc').attr("src","/public/uploads/"+res.url);
                    $('#img').val(res.url);
                } else {
                    layer.msg(res.message);
                }
            }
            ,error: function(index, upload){
                layer.closeAll('loading'); //关闭loading
            }
        });
    });
</script>

<!--页面JS脚本-->
</body>
</html>

